<!--{template Header.htm}-->
<script type="text/javascript" src="{$base_url}/views/assets/js/jquery.qeditor.js"></script>
<style type="text/css">
    @import url("http://cdn.staticfile.org/font-awesome/4.0.3/css/font-awesome.min.css");
    @import url("{$base_url}/views/assets/css/qeditor.css");
</style>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="javascript:history.back();"></a>

    <h1 class="mui-title">{$title}</h1>
</header>
<div class="mui-content">
    <form class="mui-input-group">
        <h5>分类：</h5>

        <div class="mui-input-row">
            <select name="category" id="category" class="mui-left">
                <!--{foreach $categories as $category}-->
                <option value="{$category['id']}">
                    <!--{$category['name']}-->
                </option>
                <!--{/foreach}-->
            </select>
        </div>
        <h5>标题：(支持<a href="{$base_url}/admin.php?c=Ubb" target="_blank">UBB</a>)</h5>

        <div class="mui-input-row">
            <input type="text" id="title" name="title" placeholder="50字以内" class="mui-input-clear mui-input"/>
        </div>
        <h5>内容：</h5>
        <textarea id="content" name="content" placeholder="这里是文章内容" rows="6"></textarea>
    </form>
    <div class="mui-content-padded">
        <button class="mui-btn mui-btn-block mui-btn-primary" onclick="articleAdd()">添加</button>
    </div>
    <div class="loader hide"></div>
</div>
<script type="text/javascript">
    jQuery("#content").qeditor({});

    function articleAdd() {
        var category = jQuery.trim(jQuery("#category").val());
        var title = jQuery.trim(jQuery("#title").val());
        var content = jQuery.trim(jQuery("#content").val());
        if (title == "") {
            alert("标题不能为空！");
            //noinspection JSValidateTypes
            return false;
        } else if (content == "") {
            alert("内容不能为空！");
            //noinspection JSValidateTypes
            return false;
        }
        jQuery(".loader").show();
        title = encodeURIComponent(title);
        content = encodeURIComponent(content);
        jQuery.post("{$base_url}/admin.php?c=ArticleManage&a=add", {
            token: '{$token}',
            category: category,
            title: title,
            content: content
        }, function (result) {
            jQuery(".loader").hide();
            if (confirm(result + "\n需要继续添加文章吗？")) {
                window.location = "{$base_url}/admin.php?c=ArticleManage&a=add&token={$token}";
            } else {
                window.location = "{$base_url}/admin.php?c=ArticleManage&token={$token}";
            }
        }, "text");
        //noinspection JSValidateTypes
        return false; // 阻止表单提交
    }
</script>
<!--{template Footer.htm}-->